#! /bin/sh
#
# mlcient	Start/Stop the MonALISA host sensor
#
# description: The MonALISA host sensor that publishes host monitoring information
#
#
# processname: perl host_sensor.pl
# config:

# Source function library.
. /etc/init.d/functions

# Get aaf-mlclient config
[ -f /etc/sysconfig/aaf-mlclient ] && . /etc/sysconfig/aaf-mlclient

# Get config.
. /etc/sysconfig/network

# Check that networking is up.
if [ ${NETWORKING} = "no" ]
then
	exit 0
fi

RETVAL=0
prog="mlclient"

start() {
        echo -n "Starting $prog: "
        daemon --user $AAF_MONALISA_USER $AAF_MONALISA_DIR/runMonalisa.sh
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ]
        return $RETVAL
}

stop() {
        echo -n $"Stopping $prog: "
        pkill -f perl_monalisa.pl
        RETVAL=0
        echo
        [ $RETVAL -eq 0 ]
	return $RETVAL
}

# See how we were called.
case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  restart|reload)
	stop
	start
	;;
  condrestart)
	if [ -f /var/lock/subsys/mlclient ]; then
            stop
            start
        fi
	;;
  *)
	echo  $"Usage: $0 {start|stop|restart|reload|condrestart}"
	exit 1
esac

exit $RETVAL

